<template>
    <h2>登录</h2>
    <table>
        <tr>
            <td>账号</td>
            <td>
                <input type="text" v-model="prist.name">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="prist.pwd">
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="登录" @click="lojnklw">
            </td>
        </tr>
    </table>
  </template>
  
  <script setup lang="ts">
  import {reactive, toRefs} from 'vue'
  import {useRouter,useRoute} from 'vue-router'
  import axios from 'axios'
  const router=useRouter()
  const route=useRoute()

  let data=reactive({
    prist:{
        name:'',
        pwd:''
    }
  })
  let {prist} =toRefs(data)

  const lojnklw=()=>{
    if(prist.value.name==""){
        alert("账号不能为空")
        return;
    }
    if(prist.value.pwd==""){
        alert("密码不能为空")
        return;
    }
    let obj={
        username:prist.value.name,
        password:prist.value.pwd
    }
    axios({
        url:'/api/Store/Login',
        method:'get',
        params:obj
    })
    .then(res=>{
        if(res.data.data!=null){
            alert("登录成功")
            router.push('addstore')
        }else{
            alert("用户名或者密码错误")
        }
    })
  }
  </script>
  
  <style scoped>
  
  </style>